package com.complex.spring.advance.aop.proxy.sample;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/**
 * 实现一个统一的调用处理类,它的作用就是advice
 * 可以处理一种类型的joinpoint
 * @author gao
 *
 */
public class RequestCtrlInvocationHandler implements InvocationHandler{
	private Object target;
	public RequestCtrlInvocationHandler(Object target){
		this.target = target;
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		//对于方法名为request的调用. 切入aspect
		if(method.getName().equals("request")){
			System.out.println("处理切入逻辑");
		}
		return method.invoke(target, args);
	}

	public Object getTarget() {
		return target;
	}

	public void setTarget(Object target) {
		this.target = target;
	}
	
}
